package cn.huanzi.qch.baseadmin.config.security;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @author henryC
 * @createTime 2021/1/13 9:59
 * @description
 */

@Configuration
public class MvcConfig extends WebMvcConfigurationSupport {
    @Value("${fileDir}")
    private String fileDir;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/resources/")
                .addResourceLocations("classpath:/static/")
                .addResourceLocations("classpath:/public/");
        super.addResourceHandlers(registry);
        /**
         * @Description: 对文件的路径进行配置, 创建一个虚拟路径/file/**
         *这是图片的物理路径 "file:/+本地图片的地址"
         * @Date： Create in 21:36 2018/11/08
         */
        String url = fileDir;
        registry.addResourceHandler("/file/**").addResourceLocations("file:" + url);
        super.addResourceHandlers(registry);
    }
}

